package com.demo.validation.custom;


import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.regex.Pattern;

public class LetterValidator implements ConstraintValidator<Letter, String> {

    private static final Pattern pattern = Pattern.compile("[a-zA-Z]+");

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        return pattern.matcher(value).matches();
    }

    public static void main(String[] args) {
        boolean result = pattern.matcher("1").matches();
        System.out.println(result);
    }
}